package com.hbzjt2012.lesson04;

import javax.swing.*;
import java.awt.*;

public class JFrameDemo02 {
    public static void main(String[] args) {
        new MyJFrame02().init();
    }
}

class MyJFrame02 extends JFrame{
    public void init(){

        this.setBounds(100,100,200,200);
        this.setVisible(true);

        // 设置文字 JLable
        JLabel label = new JLabel("测试标签");
        this.add(label);

        // 让文本标签居中
        label.setHorizontalAlignment(SwingConstants.CENTER);

        // 获得容器
        Container container = this.getContentPane();
        container.setBackground(Color.blue);

        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}
